var mysqlWrap = require("./mysqlWrap");

var userDao = {};

/**************************************************************************************************************
 * get all users
 **************************************************************************************************************/
userDao.selectAllUsers = function(callback) {
    mysqlWrap.getConnection(function(connection) {
        let sql = "select * from user";
        connection.query(sql, function(err, rs) {
            callback(rs);
        })
    })
};

/**************************************************************************************************************
 * login from mysql
 **************************************************************************************************************/
userDao.login = function(username, password, callback) {
    mysqlWrap.getConnection(function(connection) {
        let sql = "select * from user where userName = '" + username + "' and userPassword = '" + password+"'";
        console.log(sql);
        connection.query(sql, function(err, rs) {
            callback(rs);
        })
    })
};

module.exports = userDao;
// exports.selectAllUsers = selectAllUsers;